#!/usr/bin/env python

# Write a program that given a file containing a list of words (one
# word per line, no spaces, all lower case) identifies the longest
# word in the file that can be constructed by concatenating copies of
# shorter words also found in the file.

class LongestComposition():
    def __init__( self, words ):
        self.wordset = set(words)
        self.words = list(self.wordset)

    def composed(self, word):
        for i in range(1,len(word)):
            pre = word[0:i]
            post = word[i:len(word)+1]
            if ( pre in self.wordset and
                 ( post in self.wordset or self.composed(post) ) ):
                return True
        return False

    def run(self):
        result = ""
        for word in self.words:
            if ( len(word) < len(result)):
                continue
            if (self.composed(word)):
                result = word
        return result
        
if __name__ == "__main__":
    import sys
    words = [ i.strip() for i in sys.stdin ]
    lc = LongestComposition( words )
    result = lc.run()
    print "Result %d %s"%(len(result), result)
 
